(function(){"use strict";BX.namespace("BX.Landing.Component");BX.Landing.Component.Demo=function(){this.wrapper=BX("grid-tile-wrap");this.inner=BX("grid-tile-inner");this.navigation=BX("landing-demo-navigation");this.workarea=BX("workarea-content");this.loader=new BX.Loader;if(!this.wrapper||!this.inner){return}if(!this.navigation){this.navigation=BX.create("div",{props:{id:"landing-demo-navigation",className:"landing-navigation"}});BX.Dom.insertAfter(this.navigation,this.wrapper)}this.isTitleShow=false;this.startHeight=0;this.tileTitleCurrent=null;this.onTileTitleClick=this.onTileTitleClick.bind(this);this.onTileTitleLeave=this.onTileTitleLeave.bind(this);this.onPseudoLinkClick=this.onPseudoLinkClick.bind(this);this.init();top.BX.addCustomEvent(top,"Rest:AppLayout:ApplicationInstall",BX.delegate(this.onAppInstall,this));BX.addCustomEvent("BX.Main.Filter:apply",BX.delegate(this.onFilterApply,this));BX.addCustomEvent("BX.Main.Filter:beforeApply",BX.delegate(this.onBeforeFilterApply,this))};BX.Landing.Component.Demo.CLASS_TILE="landing-item";BX.Landing.Component.Demo.CLASS_DESC_OPEN="landing-item-desc-open";BX.Landing.Component.Demo.CLASS_DESC_DESIGNED="landing-item-designed";BX.Landing.Component.Demo.prototype={init:function(){this.links=[].slice.call(this.inner.querySelectorAll(".landing-template-pseudo-link"));this.bindPseudoLinks();this.linkEmpty=BX("landing-demo-empty");BX.Event.bind(this.linkEmpty,"click",this.onPseudoLinkClick);this.tiles=[].slice.call(this.inner.querySelectorAll("."+BX.Landing.Component.Demo.CLASS_TILE));this.createTileList();this.bindTileTitles()},reinit:function(){this.unbindPseudoLinks();this.unbindTileTitles();this.tiles=[];this.links=[];this.init()},bindPseudoLinks:function(){this.links.forEach((i=>{if(!BX.Dom.hasClass(i,"landing-item-payment")){BX.Event.bind(i,"click",this.onPseudoLinkClick)}}))},unbindPseudoLinks:function(){this.links.forEach((i=>{if(!BX.Dom.hasClass(i,"landing-item-payment")){BX.Event.unbind(i,"click",this.onPseudoLinkClick)}}))},onPseudoLinkClick:function(i){if(BX.Dom.hasClass(i.target,BX.Landing.Component.Demo.CLASS_DESC_OPEN)||BX.Dom.hasClass(i.target,BX.Landing.Component.Demo.CLASS_DESC_DESIGNED)){return}const t=i.currentTarget;const e=i.currentTarget.dataset.href;BX.SidePanel.Instance.open(e,{allowChangeHistory:false,width:t.dataset.sliderWidth?parseInt(t.dataset.sliderWidth):null,data:{rightBoundary:0},customLeftBoundary:60,events:{onClose:function(i){const t=e.split("?")[0];const n=i.slider.iframeSrc.split("?")[0];if(t!==n&&e.indexOf("frameMode=Y")<0){top.location.reload()}}}})},createTileList:function(){new BX.Landing.TileGrid({wrapper:this.wrapper,inner:this.inner,tiles:this.tiles,sizeSettings:{minWidth:250,maxWidth:281}})},bindTileTitles:function(){this.tiles.forEach((i=>{const t=i.querySelector("."+BX.Landing.Component.Demo.CLASS_DESC_OPEN);if(t){BX.Event.bind(t,"click",this.onTileTitleClick);BX.Event.bind(i,"mouseleave",this.onTileTitleLeave)}}),this)},unbindTileTitles:function(){this.tiles.forEach((i=>{const t=i.querySelector("."+BX.Landing.Component.Demo.CLASS_DESC_OPEN);if(t){BX.Event.unbind(t,"click",this.onTileTitleClick);BX.Event.unbind(t,"mouseleave",this.onTileTitleLeave)}}),this)},onTileTitleClick:function(i){i.preventDefault();const t=i.currentTarget.closest("."+BX.Landing.Component.Demo.CLASS_TILE);this.showTileTitle(t)},onTileTitleLeave:function(i){const t=i.currentTarget.closest("."+BX.Landing.Component.Demo.CLASS_TILE);this.hideTileTitle(t)},showTileTitle:function(i){this.tileTitleCurrent=i.querySelector(".landing-item-desc-inner");const t=i.querySelector(".landing-item-desc-height");i.classList.add("landing-tile-title-show");this.startHeight=BX.style(this.tileTitleCurrent,"height");this.tileTitleCurrent.style.height=t.offsetHeight+"px";this.isTitleShow=true},hideTileTitle:function(i){if(this.isTitleShow){this.tileTitleCurrent.style.height=this.startHeight;setTimeout(function(){i.classList.remove("landing-tile-title-show");this.tileTitleCurrent.style.paddingTop=0;this.tileTitleCurrent.style.marginBottom=0}.bind(this),230);this.isTitleShow=false}},onAppInstall:function(i){window.location.reload()},onBeforeFilterApply:function(){this.loader.show(this.workarea)},onFilterApply:function(i,t,e,n,s){if(s){s.autoResolve=false}BX.ajax({method:"POST",dataType:"html",url:BX.Landing.Component.Demo.ajaxPath,onsuccess:i=>{const t=BX.Dom.create("div",{html:i});this.inner.innerHTML=t.querySelector("#grid-tile-inner").innerHTML;const e=t.querySelector("#landing-demo-navigation");if(e){this.navigation.innerHTML=t.querySelector("#landing-demo-navigation").innerHTML}else{BX.Dom.clean(this.navigation)}this.reinit();n.fulfill();this.loader.hide()}})}}})();BX.ready((function(){new BX.Landing.Component.Demo}));
//# sourceMappingURL=script.map.js